package xcmg.device.infra.enums;

import org.apache.commons.lang.StringUtils;

/**
 * Created by sqq on 2018/1/3.
 */
public enum PurchaseType {
    exigency(1, "紧急"),
    replenish(2, "补库"),
    monthly(3,"月度"),
    serviceProcess(4,"三包");

    private String desc;
    private int code;

    PurchaseType(int code, String desc) {
        this.desc = desc;
        this.code = code;
    }

    public String getDesc()
    {
        return desc;
    }

    public int getCode()
    {
        return code;
    }

    /**
     * 根据code获取对应类型的枚举实例
     *
     * @param code
     * @return
     */
    public static PurchaseType getByCode(Integer code) {
        if (null == code) {
            return null;
        }

        for (PurchaseType type : PurchaseType.values()) {
            if (code.equals(type.getCode())) {
                return type;
            }
        }
        return null;
    }
}
